const compiler = require('vue-template-compiler')
// 基本
// const template = `<div style='color:red;'>{{message}}</div>`
//  with(this){return _c('div',{staticStyle:{"color":"red"}},[_v(_s(message))])}
 /**
  * render函数 与sambbdom h函数 类似
  * this  => new Vue();
  * _c => createElement()
  * _v => createTextVnode()
  * _s => toString()
  * staticStyle => html style 属性
  */

// 表达式
// const template = `<div>{{flag?message: 'no word'}}</div>`
//with(this){return _c('div',[_v(_s(flag?message: 'no word'))])}

// 动态属性
// const template = 
// `<div data-set='1'>
//   <img :src='imgUrl'>
// </div>`
// with(this){return _c('div',{attrs:{"data-set":"1"}},[_c('img',{attrs:{"src":imgUrl}})])}

// 条件
// const template = `
// <div data-set='1'>
//   <img v-if='flag' :src='imgUrl'>
//   <p v-else-if='yflag'>yesyes<p>
//   <p v-else> non</p>
// </div>
// `
// with(this){return _c('div',{attrs:{"data-set":"1"}},[(flag)?_c('img',{attrs:{"src":imgUrl}}):(yflag)?_c('p',[_v("yesyes")]):_e(),_c('p')])}

// 条件渲染
// const template = `
//   <ul>
//     <li v-for='item in list' :key='item.id'>{{item.label}}</li>
//   </ul>
// `
// with(this){return _c('ul',_l((list),function(item){return _c('li',{key:item.id},[_v(_s(item.label))])}),0)}

// 事件
// const template = `
//   <div>
//     <p @click='doSomething'></p>
//   </div>
// `
// with(this){return _c('div',[_c('p',{on:{"click":doSomething}})])}

// v-model
const template = `
  <div>
    <input v-model='groupName' />
  </div>
`
// with(this){return _c('div',[_c('input',{directives:[{name:"model",rawName:"v-model",value:(groupName),expression:"groupName"}],domProps:{"value":(groupName)},on:{"input":function($event){if($event.target.composing)return;groupName=$event.target.value}}})])}
/**
 * compilerTem 中包含 多个属性 重要的为一下两种属性
 * @attr ast
 * @attr render
 */

const compilerTem = compiler.compile(template);



 console.log(compilerTem.render);
 
 /**
  * vue实例中自定义方法
  * 
    export function installRenderHelpers (target: any) {
      target._o = markOnce
      target._n = toNumber
      target._s = toString
      target._l = renderList
      target._t = renderSlot
      target._q = looseEqual
      target._i = looseIndexOf
      target._m = renderStatic
      target._f = resolveFilter
      target._k = checkKeyCodes
      target._b = bindObjectProps
      target._v = createTextVNode
      target._e = createEmptyVNode
      target._u = resolveScopedSlots
      target._g = bindObjectListeners
      target._d = bindDynamicKeys
      target._p = prependModifier
    }
  */


